
<h1><span class="yiyi-st" id="yiyi-12">numpy.empty</span></h1>
        <blockquote>
        <p>原文：<a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.empty.html">https://docs.scipy.org/doc/numpy/reference/generated/numpy.empty.html</a></p>
        <p>译者：<a href="https://github.com/wizardforcel">飞龙</a> <a href="http://usyiyi.cn/">UsyiyiCN</a></p>
        <p>校对：（虚位以待）</p>
        </blockquote>
    
<dl class="function">
<dt id="numpy.empty"><span class="yiyi-st" id="yiyi-13"> <code class="descclassname">numpy.</code><code class="descname">empty</code><span class="sig-paren">(</span><em>shape</em>, <em>dtype=float</em>, <em>order=&apos;C&apos;</em><span class="sig-paren">)</span></span></dt>
<dd><p><span class="yiyi-st" id="yiyi-14">返回给定形状和类型的新数组，而不初始化条目。</span></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name">
<col class="field-body">
<tbody valign="top">
<tr class="field-odd field"><th class="field-name"><span class="yiyi-st" id="yiyi-15">参数：</span></th><td class="field-body"><p class="first"><span class="yiyi-st" id="yiyi-16"><strong>shape</strong>：int或tuple</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-17">空数组的形状</span></p>
</div></blockquote>
<p><span class="yiyi-st" id="yiyi-18"><strong>dtype</strong>：数据类型，可选</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-19">所需的输出数据类型。</span></p>
</div></blockquote>
<p><span class="yiyi-st" id="yiyi-20"><strong>order</strong>：{&apos;C&apos;，&apos;F&apos;}，可选</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-21">是否在存储器中以行主（C风格）或列主（Fortran风格）顺序存储多维数据。</span></p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name"><span class="yiyi-st" id="yiyi-22">返回：</span></th><td class="field-body"><p class="first"><span class="yiyi-st" id="yiyi-23"><strong>out</strong>：ndarray</span></p>
<blockquote class="last">
<div><p><span class="yiyi-st" id="yiyi-24">给定形状，dtype和顺序的未初始化（任意）数据的数组。</span><span class="yiyi-st" id="yiyi-25">对象数组将初始化为无。</span></p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title"><span class="yiyi-st" id="yiyi-26">也可以看看</span></p>
<p class="last"><span class="yiyi-st" id="yiyi-27"><a class="reference internal" href="numpy.empty_like.html#numpy.empty_like" title="numpy.empty_like"><code class="xref py py-obj docutils literal"><span class="pre">empty_like</span></code></a>，<a class="reference internal" href="numpy.zeros.html#numpy.zeros" title="numpy.zeros"><code class="xref py py-obj docutils literal"><span class="pre">zeros</span></code></a>，<a class="reference internal" href="numpy.ones.html#numpy.ones" title="numpy.ones"><code class="xref py py-obj docutils literal"><span class="pre">ones</span></code></a></span></p>
</div>
<p class="rubric"><span class="yiyi-st" id="yiyi-28">笔记</span></p>
<p><span class="yiyi-st" id="yiyi-29"><a class="reference internal" href="#numpy.empty" title="numpy.empty"><code class="xref py py-obj docutils literal"><span class="pre">empty</span></code></a>与<a class="reference internal" href="numpy.zeros.html#numpy.zeros" title="numpy.zeros"><code class="xref py py-obj docutils literal"><span class="pre">zeros</span></code></a>不同，不会将数组值设置为零，因此可能略微更快。</span><span class="yiyi-st" id="yiyi-30">另一方面，它要求用户手动设置数组中的所有值，并且应谨慎使用。</span></p>
<p class="rubric"><span class="yiyi-st" id="yiyi-31">例子</span></p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">empty</span><span class="p">([</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">])</span>
<span class="go">array([[ -9.74499359e+001,   6.69583040e-309],</span>
<span class="go">       [  2.13182611e-314,   3.06959433e-309]])         #random</span>
</pre></div>
</div>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">empty</span><span class="p">([</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">],</span> <span class="n">dtype</span><span class="o">=</span><span class="nb">int</span><span class="p">)</span>
<span class="go">array([[-1073741821, -1067949133],</span>
<span class="go">       [  496041986,    19249760]])                     #random</span>
</pre></div>
</div>
</dd></dl>
